// pages/expData/1082/1082.js
const server = require("../server.js")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        innerHtml:[],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let inner = [];
        for (i = 1; i <= 106; i++) {
            inner.push("");
        }
        this.setData({
            innerHtml: inner,
        });
    },

    onInput: function (e) {
        let index = parseInt(e.currentTarget.id.replace("i", ""));
        let value = e.detail.value;
        let inner = this.data.innerHtml;
        inner[index] = value;
        this.setData({
            innerHtml: inner,
        });
    },

    parseData: function() {
        let ret = {v:[]};
        for (i = 0; i < this.data.innerHtml.length; i++) {
            ret.v.push(this.data.innerHtml[i]);
        }
        return ret;
    },

    formSubmit:function() {
        server.pushToServer(1021,JSON.stringify(this.parseData()));
    },
    receiveData:function(e) {
        server.fetchFromServer(1021).then(res => this.changeData(res))
    },

    changeData: function(res) {
        this.setData({
            innerHtml: res.v,
        });
    }
})


// // pages/expData/1022.js
// const server = require("../server.js")
// Page({

//     /**
//      * 页面的初始数据
//      */
//     data: {
//         table1data:[
//             {"code":"时间(s)","data":[0,15,30,60,120,135,150]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入"],"index":1},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入"],"index":1},
//             {"code":"时间(s)","data":[165,180,195,210,225,240,255]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入"],"index":2},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入"],"index":2},
//             {"code":"时间(s)","data":[270,285,300,330,360,420,480]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入"],"index":3},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入"],"index":3},
//         ],
//         table2data:[
//             {"code":"时间(min)","data":[0,1,2,3,4,5,6,7]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":1},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":1},
//             {"code":"时间(min)","data":[8,9,10,11,12,13,14,15]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":2},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":2},
//             {"code":"时间(min)","data":[16,17,18,19,20,21,22,23]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":3},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":3},
//             {"code":"时间(min)","data":[24,25,26,27,28,29,30,"环境温度"]},
//             {"code":"阻值(kΩ)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":4},
//             {"code":"温度(°C)","data":["输入","输入","输入","输入","输入","输入","输入","输入"],"index":4},
//         ],
//     },

//     parseData:function(e) {
//         var parse={}
//         var v = e.detail.value
//         parse["1_R"]=[v["1_R11"],v["1_R12"],v["1_R13"],v["1_R14"],v["1_R15"],v["1_R16"],v["1_R17"],
//         v["1_R21"],v["1_R22"],v["1_R23"],v["1_R24"],v["1_R25"],v["1_R26"],v["1_R27"],
//         v["1_R31"],v["1_R32"],v["1_R33"],v["1_R34"],v["1_R35"],v["1_R36"],v["1_R37"]]
//         parse["1_T"]=[v["1_T11"],v["1_T12"],v["1_T13"],v["1_T14"],v["1_T15"],v["1_T16"],v["1_T17"],
//         v["1_T21"],v["1_T22"],v["1_T23"],v["1_T24"],v["1_T25"],v["1_T26"],v["1_T27"],
//         v["1_T31"],v["1_T32"],v["1_T33"],v["1_T34"],v["1_T35"],v["1_T36"],v["1_T37"]]
//         parse["2_R"]=[v["2_R11"],v["2_R12"],v["2_R13"],v["2_R14"],v["2_R15"],v["2_R16"],v["2_R17"],v["2_R18"],
//         v["2_R21"],v["2_R22"],v["2_R23"],v["2_R24"],v["2_R25"],v["2_R26"],v["2_R27"],v["2_R28"],
//         v["2_R31"],v["2_R32"],v["2_R33"],v["2_R34"],v["2_R35"],v["2_R36"],v["2_R37"],v["2_R38"],
//         v["2_R41"],v["2_R42"],v["2_R43"],v["2_R44"],v["2_R45"],v["2_R46"],v["2_R47"],v["2_R48"]]
//         parse["2_T"]=[v["2_T11"],v["2_T12"],v["2_T13"],v["2_T14"],v["2_T15"],v["2_T16"],v["2_T17"],v["2_T18"],
//         v["2_T21"],v["2_T22"],v["2_T23"],v["2_T24"],v["2_T25"],v["2_T26"],v["2_T27"],v["2_T28"],
//         v["2_T31"],v["2_T32"],v["2_T33"],v["2_T34"],v["2_T35"],v["2_T36"],v["2_T37"],v["2_T38"],
//         v["2_T41"],v["2_T42"],v["2_T43"],v["2_T44"],v["2_T45"],v["2_T46"],v["2_T47"],v["2_T48"]]
//         return parse;
//     },
//     formSubmit(e) {
//         console.log(e)
//         var parse = this.parseData(e)
//         var str = JSON.stringify(parse)
//         console.log(str)
//         server.pushToServer(1021,str)
//     },
//     changeData:function(res) {
//         var data = res
//         this.setData({
//             table1data:[
//                 {"code":"时间(s)","data":[0,15,30,60,120,135,150]},
//                 {"code":"阻值(kΩ)","data":data["1_R"].slice(0,7),"index":1},
//                 {"code":"温度(°C)","data":data["1_T"].slice(0,7),"index":1},
//                 {"code":"时间(s)","data":[165,180,195,210,225,240,255]},
//                 {"code":"阻值(kΩ)","data":data["1_R"].slice(7,14),"index":2},
//                 {"code":"温度(°C)","data":data["1_T"].slice(7,14),"index":2},
//                 {"code":"时间(s)","data":[270,285,300,330,360,420,480]},
//                 {"code":"阻值(kΩ)","data":data["1_R"].slice(14,21),"index":3},
//                 {"code":"温度(°C)","data":data["1_T"].slice(14,21),"index":3},
//             ],
//             table2data:[
//                 {"code":"时间(min)","data":[0,1,2,3,4,5,6,7]},
//                 {"code":"阻值(kΩ)","data":data["2_R"].slice(0,8),"index":1},
//                 {"code":"温度(°C)","data":data["2_T"].slice(0,8),"index":1},
//                 {"code":"时间(min)","data":[8,9,10,11,12,13,14,15]},
//                 {"code":"阻值(kΩ)","data":data["2_R"].slice(8,16),"index":2},
//                 {"code":"温度(°C)","data":data["2_T"].slice(8,16),"index":2},
//                 {"code":"时间(min)","data":[16,17,18,19,20,21,22,23]},
//                 {"code":"阻值(kΩ)","data":data["2_R"].slice(16,24),"index":3},
//                 {"code":"温度(°C)","data":data["2_T"].slice(16,24),"index":3},
//                 {"code":"时间(min)","data":[24,25,26,27,28,29,30,"环境温度"]},
//                 {"code":"阻值(kΩ)","data":data["2_R"].slice(24,32),"index":4},
//                 {"code":"温度(°C)","data":data["2_T"].slice(24,32),"index":4},
//             ],
//         })
//     },
//     receiveData:function(e) {
//         server.fetchFromServer(1021).then(res => this.changeData(res))
//     },

//     /**
//      * 生命周期函数--监听页面加载
//      */
//     onLoad: function (options) {

//     },

//     /**
//      * 生命周期函数--监听页面初次渲染完成
//      */
//     onReady: function () {

//     },

//     /**
//      * 生命周期函数--监听页面显示
//      */
//     onShow: function () {

//     },

//     /**
//      * 生命周期函数--监听页面隐藏
//      */
//     onHide: function () {

//     },

//     /**
//      * 生命周期函数--监听页面卸载
//      */
//     onUnload: function () {

//     },

//     /**
//      * 页面相关事件处理函数--监听用户下拉动作
//      */
//     onPullDownRefresh: function () {

//     },

//     /**
//      * 页面上拉触底事件的处理函数
//      */
//     onReachBottom: function () {

//     },

//     /**
//      * 用户点击右上角分享
//      */
//     onShareAppMessage: function () {

//     }
// })